load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "domain",
    srcs = [
        "domain.go",
        "domain_sysvars.go",
        "domainctx.go",
        "extract.go",
        "historical_stats.go",
        "optimize_trace.go",
        "plan_replayer.go",
        "plan_replayer_dump.go",
        "runaway.go",
        "schema_checker.go",
        "schema_validator.go",
        "sysvar_cache.go",
        "test_helper.go",
        "topn_slow_query.go",
    ],
    importpath = "github.com/pingcap/tidb/domain",
    visibility = ["//visibility:public"],
    deps = [
        "//bindinfo",
        "//br/pkg/streamhelper",
        "//br/pkg/streamhelper/daemon",
        "//config",
        "//ddl",
        "//ddl/placement",
        "//ddl/schematracker",
        "//ddl/util",
        "//disttask/framework/dispatcher",
        "//disttask/framework/scheduler",
        "//disttask/framework/storage",
        "//domain/globalconfigsync",
        "//domain/infosync",
        "//domain/metrics",
        "//domain/resourcegroup",
        "//errno",
        "//infoschema",
        "//infoschema/metrics",
        "//infoschema/perfschema",
        "//keyspace",
        "//kv",
        "//meta",
        "//metrics",
        "//owner",
        "//parser/ast",
        "//parser/model",
        "//parser/mysql",
        "//parser/terror",
        "//privilege/privileges",
        "//sessionctx",
        "//sessionctx/sessionstates",
        "//sessionctx/variable",
        "//statistics/handle",
        "//store/helper",
        "//telemetry",
        "//ttl/cache",
        "//ttl/sqlbuilder",
        "//ttl/ttlworker",
        "//types",
        "//util",
        "//util/chunk",
        "//util/dbterror",
        "//util/disttask",
        "//util/domainutil",
        "//util/engine",
        "//util/etcd",
        "//util/execdetails",
        "//util/expensivequery",
        "//util/gctuner",
        "//util/globalconn",
        "//util/intest",
        "//util/logutil",
        "//util/memory",
        "//util/memoryusagealarm",
        "//util/printer",
        "//util/replayer",
        "//util/servermemorylimit",
        "//util/sqlexec",
        "//util/syncutil",
        "@com_github_burntsushi_toml//:toml",
        "@com_github_ngaut_pools//:pools",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_kvproto//pkg/metapb",
        "@com_github_pingcap_kvproto//pkg/pdpb",
        "@com_github_pingcap_kvproto//pkg/resource_manager",
        "@com_github_pingcap_log//:log",
        "@com_github_stretchr_testify//require",
        "@com_github_tikv_client_go_v2//oracle",
        "@com_github_tikv_client_go_v2//tikv",
        "@com_github_tikv_client_go_v2//txnkv/transaction",
        "@com_github_tikv_pd_client//:client",
        "@com_github_tikv_pd_client//resource_group/controller",
        "@io_etcd_go_etcd_client_v3//:client",
        "@io_etcd_go_etcd_client_v3//concurrency",
        "@org_golang_google_grpc//:grpc",
        "@org_golang_google_grpc//backoff",
        "@org_golang_google_grpc//keepalive",
        "@org_golang_x_exp//maps",
        "@org_uber_go_atomic//:atomic",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "domain_test",
    timeout = "short",
    srcs = [
        "db_test.go",
        "domain_test.go",
        "domain_utils_test.go",
        "domainctx_test.go",
        "extract_test.go",
        "main_test.go",
        "plan_replayer_handle_test.go",
        "plan_replayer_test.go",
        "schema_checker_test.go",
        "schema_validator_test.go",
        "session_pool_test.go",
        "topn_slow_query_test.go",
    ],
    embed = [":domain"],
    flaky = True,
    shard_count = 23,
    deps = [
        "//config",
        "//ddl",
        "//domain/infosync",
        "//errno",
        "//keyspace",
        "//kv",
        "//metrics",
        "//parser/ast",
        "//parser/auth",
        "//parser/model",
        "//parser/mysql",
        "//parser/terror",
        "//server",
        "//session",
        "//sessionctx/stmtctx",
        "//sessionctx/variable",
        "//store/mockstore",
        "//testkit",
        "//testkit/testsetup",
        "//types",
        "//util",
        "//util/mock",
        "//util/replayer",
        "//util/stmtsummary/v2:stmtsummary",
        "@com_github_ngaut_pools//:pools",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_kvproto//pkg/metapb",
        "@com_github_prometheus_client_model//go",
        "@com_github_stretchr_testify//require",
        "@com_github_tikv_client_go_v2//oracle",
        "@com_github_tikv_client_go_v2//txnkv/transaction",
        "@com_github_tikv_pd_client//:client",
        "@io_etcd_go_etcd_tests_v3//integration",
        "@org_uber_go_goleak//:goleak",
    ],
)
